@extends('admin.layouts.app')
@section('title','管理员登录')
@section('content')
    <div class="logintop">
        <span>DD跑腿平台管理系统</span>
        <ul>
            <li><a href="#">返回首页</a></li>
            <li><a href="#">帮助</a></li>
            <li><a href="#">关于</a></li>
        </ul>
    </div>
    <div class="loginbody">
        <div class="login-container">
            <div class="center">
                <h2>DD跑腿平台系统</h2>
            </div>

            <div class="space-6"></div>

            <div class="position-relative">
                <div id="login-box" class="login-box widget-box no-border visible">
                    <div class="widget-body">
                        <div class="widget-main">
                            <h4 class="header blue lighter bigger" style="background: none">
                                <i class="icon-coffee green"></i>
                                管理员登陆
                            </h4>

                            <div class="login_icon"><img src="{{ asset('admin/images/login.png') }}" /></div>

                            {!! Form::open(['route' => 'admin.login', 'method' => 'post','id'=>'form']) !!}
                                <fieldset>
                                    <ul>
                                        <li class="frame_style form_error"><label class="user_icon"></label><input name="name" type="text"  id="username"/><i></i></li>
                                        <li class="frame_style form_error"><label class="password_icon"></label><input name="password" type="password"   id="userpwd"/><i></i></li>
                                        <li class="frame_style form_error"><label class="Codes_icon"></label><input name="captcha" type="text"   id="captcha"/><i></i>
                                            <div class="Codes_region" style="cursor: pointer;z-index: 99;">
                                                <img class="thumbnail captcha mt-5 mb-3" src="{{ captcha_src('mini') }}" onclick="this.src='/captcha/mini?'+Math.random()" title="点击图片重新获取验证码">
                                            </div></li>

                                    </ul>
                                    <div class="space"></div>

                                    <div class="clearfix">

                                        <button type="submit" class="width-35 pull-left btn btn-sm btn-primary" id="login_btn">
                                            <i class="icon-key"></i>
                                            登陆
                                        </button>
                                    </div>

                                    <div class="space-4"></div>
                                </fieldset>
                            {!! Form::close() !!}

                            <div class="social-or-login center">
                                <span class="bigger-110">通知</span>
                            </div>

                            <div class="social-login center">
                                本网站系统不再对IE8以下浏览器支持，请见谅。
                            </div>
                        </div><!-- /widget-main -->

                        <div class="toolbar clearfix">



                        </div>
                    </div><!-- /widget-body -->
                </div><!-- /login-box -->
            </div><!-- /position-relative -->
        </div>
    </div>
    <div class="loginbm">软件开发  2020   <a href="">淮北鑫畅信息技术有限公司</a> </div><strong></strong>
    @yield('js')
    <script>
        $(function () {
            $("body").attr("class","login-layout Reg_log_style");

        })
    </script>
    <script>
        $('#form').Validform({
            tiptype : 4,
            ajaxPost : true,
            beforeCheck:function(curform){
                console.log(curform);
                //在表单提交执行验证之前执行的函数，curform参数是当前表单对象。
                //这里明确return false的话将不会继续执行验证操作;
                let name = $('#username').val();
                let password = $('#userpwd').val();
                if (name.length == 0) {
                    layer.msg('用户名不能为空', {icon: 5});
                    return false;
                }
                if (password.length == 0) {
                    layer.msg('密码不能为空', {icon: 5});
                    return false;
                }
            },
            callback : function (res) {
                console.log(res);

                if(res.status == 422) {
                    var json=JSON.parse(res.responseText);
                    $.each(json.errors, function(idx, obj) {
                        layer.msg(obj[0], {icon: 5});
                        return false;
                    });
                } else if(res.status== 200) {
                    layer.msg('登录成功', {icon: 1});
                    location.href = '{{ route('admin.index') }}'
                }
            },
        });
    </script>
@stop
